<template>
    <p>这是Product页面</p>
  </template>
  
  <script>
    export default {
      watch:{
        $route(newVal, oldVal){
          console.log('newVal',newVal);
          console.log('oldVal',oldVal);
          // 触发初始化的逻辑
          this.init()
        }
      },
      methods:{
        init(){
          console.log("初始化数据");
          console.log("现在的id是 "+this.$route.params.id);
        }
      },
      mounted () {
        console.log("mounted生命周期函数触发了");
        console.log(this.$route);;
      },
    }
  </script>
  
  <style scoped>
  
  </style>